using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex{
    /// <summary>
    /// Strongly-typed collection for the VSiteUser class.
    /// </summary>
    [Serializable]
    public partial class VSiteUserCollection : ReadOnlyList<VSiteUser, VSiteUserCollection>
    {        
        public VSiteUserCollection() {}

    }

    /// <summary>
    /// This is  Read-only wrapper class for the vSiteUser view.
    /// </summary>
    [Serializable]
    public partial class VSiteUser : ReadOnlyRecord<VSiteUser> 
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }

	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }

                return BaseSchema;
            }

        }

    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vSiteUser", TableType.View, DataService.GetInstance("Adex"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = "dbo";
                //columns
                
                TableSchema.TableColumn colvarRoleName = new TableSchema.TableColumn(schema);
                colvarRoleName.ColumnName = "RoleName";
                colvarRoleName.DataType = DbType.String;
                colvarRoleName.MaxLength = 256;
                colvarRoleName.AutoIncrement = false;
                colvarRoleName.IsNullable = false;
                colvarRoleName.IsPrimaryKey = false;
                colvarRoleName.IsForeignKey = false;
                colvarRoleName.IsReadOnly = false;
                
                schema.Columns.Add(colvarRoleName);
                
                TableSchema.TableColumn colvarCompanyName = new TableSchema.TableColumn(schema);
                colvarCompanyName.ColumnName = "CompanyName";
                colvarCompanyName.DataType = DbType.String;
                colvarCompanyName.MaxLength = 255;
                colvarCompanyName.AutoIncrement = false;
                colvarCompanyName.IsNullable = true;
                colvarCompanyName.IsPrimaryKey = false;
                colvarCompanyName.IsForeignKey = false;
                colvarCompanyName.IsReadOnly = false;
                
                schema.Columns.Add(colvarCompanyName);
                
                TableSchema.TableColumn colvarPassword = new TableSchema.TableColumn(schema);
                colvarPassword.ColumnName = "Password";
                colvarPassword.DataType = DbType.String;
                colvarPassword.MaxLength = 128;
                colvarPassword.AutoIncrement = false;
                colvarPassword.IsNullable = false;
                colvarPassword.IsPrimaryKey = false;
                colvarPassword.IsForeignKey = false;
                colvarPassword.IsReadOnly = false;
                
                schema.Columns.Add(colvarPassword);
                
                TableSchema.TableColumn colvarUserID = new TableSchema.TableColumn(schema);
                colvarUserID.ColumnName = "UserID";
                colvarUserID.DataType = DbType.Guid;
                colvarUserID.MaxLength = 0;
                colvarUserID.AutoIncrement = false;
                colvarUserID.IsNullable = false;
                colvarUserID.IsPrimaryKey = false;
                colvarUserID.IsForeignKey = false;
                colvarUserID.IsReadOnly = false;
                
                schema.Columns.Add(colvarUserID);
                
                TableSchema.TableColumn colvarSiteUserID = new TableSchema.TableColumn(schema);
                colvarSiteUserID.ColumnName = "SiteUserID";
                colvarSiteUserID.DataType = DbType.Int32;
                colvarSiteUserID.MaxLength = 0;
                colvarSiteUserID.AutoIncrement = false;
                colvarSiteUserID.IsNullable = false;
                colvarSiteUserID.IsPrimaryKey = false;
                colvarSiteUserID.IsForeignKey = false;
                colvarSiteUserID.IsReadOnly = false;
                
                schema.Columns.Add(colvarSiteUserID);
                
                TableSchema.TableColumn colvarUserName = new TableSchema.TableColumn(schema);
                colvarUserName.ColumnName = "UserName";
                colvarUserName.DataType = DbType.String;
                colvarUserName.MaxLength = 50;
                colvarUserName.AutoIncrement = false;
                colvarUserName.IsNullable = true;
                colvarUserName.IsPrimaryKey = false;
                colvarUserName.IsForeignKey = false;
                colvarUserName.IsReadOnly = false;
                
                schema.Columns.Add(colvarUserName);
                
                TableSchema.TableColumn colvarCompanyCode = new TableSchema.TableColumn(schema);
                colvarCompanyCode.ColumnName = "CompanyCode";
                colvarCompanyCode.DataType = DbType.Int32;
                colvarCompanyCode.MaxLength = 0;
                colvarCompanyCode.AutoIncrement = false;
                colvarCompanyCode.IsNullable = true;
                colvarCompanyCode.IsPrimaryKey = false;
                colvarCompanyCode.IsForeignKey = false;
                colvarCompanyCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarCompanyCode);
                
                TableSchema.TableColumn colvarScreenName = new TableSchema.TableColumn(schema);
                colvarScreenName.ColumnName = "ScreenName";
                colvarScreenName.DataType = DbType.String;
                colvarScreenName.MaxLength = 50;
                colvarScreenName.AutoIncrement = false;
                colvarScreenName.IsNullable = true;
                colvarScreenName.IsPrimaryKey = false;
                colvarScreenName.IsForeignKey = false;
                colvarScreenName.IsReadOnly = false;
                
                schema.Columns.Add(colvarScreenName);
                
                TableSchema.TableColumn colvarEmail = new TableSchema.TableColumn(schema);
                colvarEmail.ColumnName = "Email";
                colvarEmail.DataType = DbType.String;
                colvarEmail.MaxLength = 100;
                colvarEmail.AutoIncrement = false;
                colvarEmail.IsNullable = true;
                colvarEmail.IsPrimaryKey = false;
                colvarEmail.IsForeignKey = false;
                colvarEmail.IsReadOnly = false;
                
                schema.Columns.Add(colvarEmail);
                
                TableSchema.TableColumn colvarCell = new TableSchema.TableColumn(schema);
                colvarCell.ColumnName = "Cell";
                colvarCell.DataType = DbType.String;
                colvarCell.MaxLength = 20;
                colvarCell.AutoIncrement = false;
                colvarCell.IsNullable = true;
                colvarCell.IsPrimaryKey = false;
                colvarCell.IsForeignKey = false;
                colvarCell.IsReadOnly = false;
                
                schema.Columns.Add(colvarCell);
                
                TableSchema.TableColumn colvarFullName = new TableSchema.TableColumn(schema);
                colvarFullName.ColumnName = "FullName";
                colvarFullName.DataType = DbType.String;
                colvarFullName.MaxLength = 100;
                colvarFullName.AutoIncrement = false;
                colvarFullName.IsNullable = true;
                colvarFullName.IsPrimaryKey = false;
                colvarFullName.IsForeignKey = false;
                colvarFullName.IsReadOnly = false;
                
                schema.Columns.Add(colvarFullName);
                
                TableSchema.TableColumn colvarPhoto = new TableSchema.TableColumn(schema);
                colvarPhoto.ColumnName = "Photo";
                colvarPhoto.DataType = DbType.String;
                colvarPhoto.MaxLength = 50;
                colvarPhoto.AutoIncrement = false;
                colvarPhoto.IsNullable = false;
                colvarPhoto.IsPrimaryKey = false;
                colvarPhoto.IsForeignKey = false;
                colvarPhoto.IsReadOnly = false;
                
                schema.Columns.Add(colvarPhoto);
                
                TableSchema.TableColumn colvarUnlockCode = new TableSchema.TableColumn(schema);
                colvarUnlockCode.ColumnName = "UnlockCode";
                colvarUnlockCode.DataType = DbType.String;
                colvarUnlockCode.MaxLength = 6;
                colvarUnlockCode.AutoIncrement = false;
                colvarUnlockCode.IsNullable = true;
                colvarUnlockCode.IsPrimaryKey = false;
                colvarUnlockCode.IsForeignKey = false;
                colvarUnlockCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarUnlockCode);
                
                TableSchema.TableColumn colvarActive = new TableSchema.TableColumn(schema);
                colvarActive.ColumnName = "Active";
                colvarActive.DataType = DbType.Boolean;
                colvarActive.MaxLength = 0;
                colvarActive.AutoIncrement = false;
                colvarActive.IsNullable = false;
                colvarActive.IsPrimaryKey = false;
                colvarActive.IsForeignKey = false;
                colvarActive.IsReadOnly = false;
                
                schema.Columns.Add(colvarActive);
                
                TableSchema.TableColumn colvarValidFrom = new TableSchema.TableColumn(schema);
                colvarValidFrom.ColumnName = "ValidFrom";
                colvarValidFrom.DataType = DbType.DateTime;
                colvarValidFrom.MaxLength = 0;
                colvarValidFrom.AutoIncrement = false;
                colvarValidFrom.IsNullable = true;
                colvarValidFrom.IsPrimaryKey = false;
                colvarValidFrom.IsForeignKey = false;
                colvarValidFrom.IsReadOnly = false;
                
                schema.Columns.Add(colvarValidFrom);
                
                TableSchema.TableColumn colvarValidTo = new TableSchema.TableColumn(schema);
                colvarValidTo.ColumnName = "ValidTo";
                colvarValidTo.DataType = DbType.DateTime;
                colvarValidTo.MaxLength = 0;
                colvarValidTo.AutoIncrement = false;
                colvarValidTo.IsNullable = true;
                colvarValidTo.IsPrimaryKey = false;
                colvarValidTo.IsForeignKey = false;
                colvarValidTo.IsReadOnly = false;
                
                schema.Columns.Add(colvarValidTo);
                
                TableSchema.TableColumn colvarBalanceAmount = new TableSchema.TableColumn(schema);
                colvarBalanceAmount.ColumnName = "BalanceAmount";
                colvarBalanceAmount.DataType = DbType.Currency;
                colvarBalanceAmount.MaxLength = 0;
                colvarBalanceAmount.AutoIncrement = false;
                colvarBalanceAmount.IsNullable = false;
                colvarBalanceAmount.IsPrimaryKey = false;
                colvarBalanceAmount.IsForeignKey = false;
                colvarBalanceAmount.IsReadOnly = false;
                
                schema.Columns.Add(colvarBalanceAmount);
                
                TableSchema.TableColumn colvarPromotionCode = new TableSchema.TableColumn(schema);
                colvarPromotionCode.ColumnName = "PromotionCode";
                colvarPromotionCode.DataType = DbType.String;
                colvarPromotionCode.MaxLength = 15;
                colvarPromotionCode.AutoIncrement = false;
                colvarPromotionCode.IsNullable = true;
                colvarPromotionCode.IsPrimaryKey = false;
                colvarPromotionCode.IsForeignKey = false;
                colvarPromotionCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarPromotionCode);
                
                TableSchema.TableColumn colvarReferralCode = new TableSchema.TableColumn(schema);
                colvarReferralCode.ColumnName = "ReferralCode";
                colvarReferralCode.DataType = DbType.String;
                colvarReferralCode.MaxLength = 15;
                colvarReferralCode.AutoIncrement = false;
                colvarReferralCode.IsNullable = true;
                colvarReferralCode.IsPrimaryKey = false;
                colvarReferralCode.IsForeignKey = false;
                colvarReferralCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarReferralCode);
                
                TableSchema.TableColumn colvarReferralType = new TableSchema.TableColumn(schema);
                colvarReferralType.ColumnName = "ReferralType";
                colvarReferralType.DataType = DbType.AnsiStringFixedLength;
                colvarReferralType.MaxLength = 1;
                colvarReferralType.AutoIncrement = false;
                colvarReferralType.IsNullable = true;
                colvarReferralType.IsPrimaryKey = false;
                colvarReferralType.IsForeignKey = false;
                colvarReferralType.IsReadOnly = false;
                
                schema.Columns.Add(colvarReferralType);
                
                TableSchema.TableColumn colvarRefUserId = new TableSchema.TableColumn(schema);
                colvarRefUserId.ColumnName = "RefUserId";
                colvarRefUserId.DataType = DbType.Int32;
                colvarRefUserId.MaxLength = 0;
                colvarRefUserId.AutoIncrement = false;
                colvarRefUserId.IsNullable = true;
                colvarRefUserId.IsPrimaryKey = false;
                colvarRefUserId.IsForeignKey = false;
                colvarRefUserId.IsReadOnly = false;
                
                schema.Columns.Add(colvarRefUserId);
                
                TableSchema.TableColumn colvarDateAdded = new TableSchema.TableColumn(schema);
                colvarDateAdded.ColumnName = "DateAdded";
                colvarDateAdded.DataType = DbType.DateTime;
                colvarDateAdded.MaxLength = 0;
                colvarDateAdded.AutoIncrement = false;
                colvarDateAdded.IsNullable = false;
                colvarDateAdded.IsPrimaryKey = false;
                colvarDateAdded.IsForeignKey = false;
                colvarDateAdded.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateAdded);
                
                TableSchema.TableColumn colvarDateModified = new TableSchema.TableColumn(schema);
                colvarDateModified.ColumnName = "DateModified";
                colvarDateModified.DataType = DbType.DateTime;
                colvarDateModified.MaxLength = 0;
                colvarDateModified.AutoIncrement = false;
                colvarDateModified.IsNullable = false;
                colvarDateModified.IsPrimaryKey = false;
                colvarDateModified.IsForeignKey = false;
                colvarDateModified.IsReadOnly = false;
                
                schema.Columns.Add(colvarDateModified);
                
                TableSchema.TableColumn colvarCountryID = new TableSchema.TableColumn(schema);
                colvarCountryID.ColumnName = "CountryID";
                colvarCountryID.DataType = DbType.Byte;
                colvarCountryID.MaxLength = 0;
                colvarCountryID.AutoIncrement = false;
                colvarCountryID.IsNullable = true;
                colvarCountryID.IsPrimaryKey = false;
                colvarCountryID.IsForeignKey = false;
                colvarCountryID.IsReadOnly = false;
                
                schema.Columns.Add(colvarCountryID);
                
                TableSchema.TableColumn colvarCountryName = new TableSchema.TableColumn(schema);
                colvarCountryName.ColumnName = "CountryName";
                colvarCountryName.DataType = DbType.String;
                colvarCountryName.MaxLength = 50;
                colvarCountryName.AutoIncrement = false;
                colvarCountryName.IsNullable = true;
                colvarCountryName.IsPrimaryKey = false;
                colvarCountryName.IsForeignKey = false;
                colvarCountryName.IsReadOnly = false;
                
                schema.Columns.Add(colvarCountryName);
                
                TableSchema.TableColumn colvarUserCountryActive = new TableSchema.TableColumn(schema);
                colvarUserCountryActive.ColumnName = "UserCountryActive";
                colvarUserCountryActive.DataType = DbType.Boolean;
                colvarUserCountryActive.MaxLength = 0;
                colvarUserCountryActive.AutoIncrement = false;
                colvarUserCountryActive.IsNullable = true;
                colvarUserCountryActive.IsPrimaryKey = false;
                colvarUserCountryActive.IsForeignKey = false;
                colvarUserCountryActive.IsReadOnly = false;
                
                schema.Columns.Add(colvarUserCountryActive);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["Adex"].AddSchema("vSiteUser",schema);
            }

        }

        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }

	    #endregion
	    
	    #region .ctors
	    public VSiteUser()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }

        public VSiteUser(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}

			MarkNew();
	    }

	    
	    public VSiteUser(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }

    	 
	    public VSiteUser(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }

        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("RoleName")]
        public string RoleName 
	    {
		    get
		    {
			    return GetColumnValue<string>("RoleName");
		    }

            set 
		    {
			    SetColumnValue("RoleName", value);
            }

        }

	      
        [XmlAttribute("CompanyName")]
        public string CompanyName 
	    {
		    get
		    {
			    return GetColumnValue<string>("CompanyName");
		    }

            set 
		    {
			    SetColumnValue("CompanyName", value);
            }

        }

	      
        [XmlAttribute("Password")]
        public string Password 
	    {
		    get
		    {
			    return GetColumnValue<string>("Password");
		    }

            set 
		    {
			    SetColumnValue("Password", value);
            }

        }

	      
        [XmlAttribute("UserID")]
        public Guid UserID 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("UserID");
		    }

            set 
		    {
			    SetColumnValue("UserID", value);
            }

        }

	      
        [XmlAttribute("SiteUserID")]
        public int SiteUserID 
	    {
		    get
		    {
			    return GetColumnValue<int>("SiteUserID");
		    }

            set 
		    {
			    SetColumnValue("SiteUserID", value);
            }

        }

	      
        [XmlAttribute("UserName")]
        public string UserName 
	    {
		    get
		    {
			    return GetColumnValue<string>("UserName");
		    }

            set 
		    {
			    SetColumnValue("UserName", value);
            }

        }

	      
        [XmlAttribute("CompanyCode")]
        public int? CompanyCode 
	    {
		    get
		    {
			    return GetColumnValue<int?>("CompanyCode");
		    }

            set 
		    {
			    SetColumnValue("CompanyCode", value);
            }

        }

	      
        [XmlAttribute("ScreenName")]
        public string ScreenName 
	    {
		    get
		    {
			    return GetColumnValue<string>("ScreenName");
		    }

            set 
		    {
			    SetColumnValue("ScreenName", value);
            }

        }

	      
        [XmlAttribute("Email")]
        public string Email 
	    {
		    get
		    {
			    return GetColumnValue<string>("Email");
		    }

            set 
		    {
			    SetColumnValue("Email", value);
            }

        }

	      
        [XmlAttribute("Cell")]
        public string Cell 
	    {
		    get
		    {
			    return GetColumnValue<string>("Cell");
		    }

            set 
		    {
			    SetColumnValue("Cell", value);
            }

        }

	      
        [XmlAttribute("FullName")]
        public string FullName 
	    {
		    get
		    {
			    return GetColumnValue<string>("FullName");
		    }

            set 
		    {
			    SetColumnValue("FullName", value);
            }

        }

	      
        [XmlAttribute("Photo")]
        public string Photo 
	    {
		    get
		    {
			    return GetColumnValue<string>("Photo");
		    }

            set 
		    {
			    SetColumnValue("Photo", value);
            }

        }

	      
        [XmlAttribute("UnlockCode")]
        public string UnlockCode 
	    {
		    get
		    {
			    return GetColumnValue<string>("UnlockCode");
		    }

            set 
		    {
			    SetColumnValue("UnlockCode", value);
            }

        }

	      
        [XmlAttribute("Active")]
        public bool Active 
	    {
		    get
		    {
			    return GetColumnValue<bool>("Active");
		    }

            set 
		    {
			    SetColumnValue("Active", value);
            }

        }

	      
        [XmlAttribute("ValidFrom")]
        public DateTime? ValidFrom 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("ValidFrom");
		    }

            set 
		    {
			    SetColumnValue("ValidFrom", value);
            }

        }

	      
        [XmlAttribute("ValidTo")]
        public DateTime? ValidTo 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("ValidTo");
		    }

            set 
		    {
			    SetColumnValue("ValidTo", value);
            }

        }

	      
        [XmlAttribute("BalanceAmount")]
        public decimal BalanceAmount 
	    {
		    get
		    {
			    return GetColumnValue<decimal>("BalanceAmount");
		    }

            set 
		    {
			    SetColumnValue("BalanceAmount", value);
            }

        }

	      
        [XmlAttribute("PromotionCode")]
        public string PromotionCode 
	    {
		    get
		    {
			    return GetColumnValue<string>("PromotionCode");
		    }

            set 
		    {
			    SetColumnValue("PromotionCode", value);
            }

        }

	      
        [XmlAttribute("ReferralCode")]
        public string ReferralCode 
	    {
		    get
		    {
			    return GetColumnValue<string>("ReferralCode");
		    }

            set 
		    {
			    SetColumnValue("ReferralCode", value);
            }

        }

	      
        [XmlAttribute("ReferralType")]
        public string ReferralType 
	    {
		    get
		    {
			    return GetColumnValue<string>("ReferralType");
		    }

            set 
		    {
			    SetColumnValue("ReferralType", value);
            }

        }

	      
        [XmlAttribute("RefUserId")]
        public int? RefUserId 
	    {
		    get
		    {
			    return GetColumnValue<int?>("RefUserId");
		    }

            set 
		    {
			    SetColumnValue("RefUserId", value);
            }

        }

	      
        [XmlAttribute("DateAdded")]
        public DateTime DateAdded 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("DateAdded");
		    }

            set 
		    {
			    SetColumnValue("DateAdded", value);
            }

        }

	      
        [XmlAttribute("DateModified")]
        public DateTime DateModified 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("DateModified");
		    }

            set 
		    {
			    SetColumnValue("DateModified", value);
            }

        }

	      
        [XmlAttribute("CountryID")]
        public byte? CountryID 
	    {
		    get
		    {
			    return GetColumnValue<byte?>("CountryID");
		    }

            set 
		    {
			    SetColumnValue("CountryID", value);
            }

        }

	      
        [XmlAttribute("CountryName")]
        public string CountryName 
	    {
		    get
		    {
			    return GetColumnValue<string>("CountryName");
		    }

            set 
		    {
			    SetColumnValue("CountryName", value);
            }

        }

	      
        [XmlAttribute("UserCountryActive")]
        public bool? UserCountryActive 
	    {
		    get
		    {
			    return GetColumnValue<bool?>("UserCountryActive");
		    }

            set 
		    {
			    SetColumnValue("UserCountryActive", value);
            }

        }

	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string RoleName = @"RoleName";
            
            public static string CompanyName = @"CompanyName";
            
            public static string Password = @"Password";
            
            public static string UserID = @"UserID";
            
            public static string SiteUserID = @"SiteUserID";
            
            public static string UserName = @"UserName";
            
            public static string CompanyCode = @"CompanyCode";
            
            public static string ScreenName = @"ScreenName";
            
            public static string Email = @"Email";
            
            public static string Cell = @"Cell";
            
            public static string FullName = @"FullName";
            
            public static string Photo = @"Photo";
            
            public static string UnlockCode = @"UnlockCode";
            
            public static string Active = @"Active";
            
            public static string ValidFrom = @"ValidFrom";
            
            public static string ValidTo = @"ValidTo";
            
            public static string BalanceAmount = @"BalanceAmount";
            
            public static string PromotionCode = @"PromotionCode";
            
            public static string ReferralCode = @"ReferralCode";
            
            public static string ReferralType = @"ReferralType";
            
            public static string RefUserId = @"RefUserId";
            
            public static string DateAdded = @"DateAdded";
            
            public static string DateModified = @"DateModified";
            
            public static string CountryID = @"CountryID";
            
            public static string CountryName = @"CountryName";
            
            public static string UserCountryActive = @"UserCountryActive";
            
	    }

	    #endregion
    }

}

